package cn.t.enums;


import cn.t.core.enums.Enumer;
import cn.t.core.enums.base.CommonEnum;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 设备异常content描述枚举
 *
 * @author s
 */
@Enumer
@Getter
@AllArgsConstructor
public enum FaultEnum implements CommonEnum<String, String> {

    SK00000("sk00000", "网络恢复"),
    SK00001("sk00001", "断网"),
    SK00002("sk00002", "称损坏"),
    SK00003("sk00003", "门锁故障"),
    SK00004("sk00004", "读卡器故障"),
    SK00005("sk00005", "刷卡成功未开锁"),
    SK00006("sk00006", "货道增重"),
    SK00007("sk00007", "超时未关门"),
    C000000F("C000000F", "设备自检");


    @JsonValue
    @EnumValue
    private final String code;
    private final String name;

    public static FaultEnum getName(String code) {
        Optional<FaultEnum> first = Arrays.stream(values()).filter(f -> f.getCode().equals(code)).findFirst();
        return first.orElse(null);
    }
}
